project(VideoStream)

find_package(PkgConfig REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(fmt REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Crow REQUIRED)

pkg_check_modules(
  gst
  REQUIRED
  IMPORTED_TARGET
  gstreamer-1.0
  gstreamer-base-1.0
  gstreamer-app-1.0
  gstreamer-mpegts-1.0)

set(ENCODER_RASPBERRY false)

if(${ENCODER} MATCHES "Raspberry")
  aux_source_directory(src/EncoderDevice/Raspberry ENCODER_SRC)
  include_directories(src/EncoderDevice/Raspberry)
else()
  aux_source_directory(src/EncoderDevice/VAAPI ENCODER_SRC)
  include_directories(src/EncoderDevice/VAAPI)
endif()

include_directories(../Thrift/Client)
include_directories(../Broadcast/inc)
aux_source_directory(src SOURCE_FILE)

link_libraries(
  PkgConfig::gst
  ClientIPC
  yaml-cpp::yaml-cpp
  fmt::fmt
  ClientSub
  ${OpenCV_LIBRARIES}
  Crow::Crow)

add_executable(${PROJECT_NAME} ${SOURCE_FILE} ${ENCODER_SRC}
                               run/VideoStream.cpp)

add_executable(Encoder_test ${SOURCE_FILE} ${ENCODER_SRC} run/EncoderTest.cpp)

add_executable(PreviewStream run/PreviewStream.cpp ${SOURCE_FILE}
                             src/EncoderDevice/MJPEGServer/MJPEGServer.cpp)
